{__NOLAYOUT__}
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport"
		  content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<title>卡券中心</title>
	{include file="public/script" /}
</head>
<body>
	<div class="sectionH  sectionH2 mui-clearfix">
		<header class="mui-bar mui-bar-nav" style="">
			<a class="mui-icon mui-icon-left-nav  mui-pull-left" href="javascript:history.back(-1)" style="color: #727272;"></a>
			<h1 class="mui-title">卡券中心</h1>
			<a class="mui-icon mui-pull-right right1" href="{:url('Resource/discountNote')}">使用说明</a>
		</header>
	</div>
	<div class="kong1"></div>
	<div class="kongdiv" style="position: absolute;z-index: 2;width: 100%;height: 94%;">
		<div class="kaquan_section1" style="position: absolute;width: 100%;z-index: 1;">
			<div class="container" style="position: relative;">
				{volist name="list" id="item"}
				<div class="a1">
					<div class="a1_1" style="background:#{$item.background}">
						<div class="a1_1_1 mui-clearfix">
							<img src="{$item.thumb}" alt="" />
							<p class="p1">{$item.title}</p>
							<p class="p2"><span><?php echo round($item['discount'],1); ?></span> 折</p>
						</div>
					</div>
					<div class="a1_2">
						<p style="word-break: break-all;" class="p1">地址：{$item.address}</p>
					</div>
				</div>
				{/volist}
			</div>
		</div>
	</div>

	
	
</body>
<script>
    mui.init({
        pullRefresh: {
            container: '.kongdiv',
            down: {

            },
            up: {
                auto:false,
                contentrefresh: '正在加载...',
                callback: pullupRefresh
            }
        }

    });

    var count = 1;
    var finish = false;
    function pullupRefresh() {
        setTimeout(function() {
            ++count;
            $.ajax({
                type: "POST",
                url: "{:url('Resource/discountList')}",
                data: {page:count},
                dataType: "json",
                success: function(data){
                    if(data.result_code==='0000'){
                        var list = data.result_data.list;
                        if(list.length===0){
                            finish=true;
                        }
                        mui('.kongdiv').pullRefresh().endPullupToRefresh((finish)); //参数为true代表没有更多数据了。
                        var table = document.body.querySelector('.container');
                        if(list.length>0){
                            for(var i=0;i<list.length;i++){
                                var discount = parseFloat(list[i]['discount']);
                                discount = discount.toFixed(1);
								var div = document.createElement('div');
                                div.className="a1";
                                div.innerHTML = '<div class="a1_1" style="background:#'+list[i]['background']+'"><div class="a1_1_1 mui-clearfix"><img src="'+list[i]['thumb']+'" alt="" /><p class="p1">'+list[i]['title']+'</p><p class="p2"><span>'+discount+'</span> 折</p></div></div><div class="a1_2"><p style="word-break: break-all;" class="p1">地址：'+list[i]['address']+'</p></div>';
                                table.appendChild(div);
                            }
                        }
                    }else if(data.result_code==='1111'){
                        mui.alert('请登录','',function(){
                            window.location.href='/Login/login';
                        });
                    }else{
                        mui.alert(data.result_info);
                    }

                }
            });
        }, 500);
    }
</script>
</html>